import pandas as pd
import numpy as np
from GCForest import gcForest
from sklearn.metrics import accuracy_score, confusion_matrix, recall_score, f1_score, precision_score
from sklearn.model_selection import train_test_split

txt = np.loadtxt('E:\program\NLP_ClusteringProject\document_term.txt')
txtDF = pd.DataFrame(txt)
txtDF.to_csv('E:\\bishe\\data1.csv', index=False)

data = pd.read_csv('E:\\bishe\\data1.csv')
# 改动点1：列数需要从文件中读取， x = 总列数-1
X = data.iloc[:, 0:2296]
X = np.array(X)
Y = data.iloc[:, -1:]
Y = np.array(Y)
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.33)

gcf = gcForest(shape_1X=2, window=1, tolerance=0.0)
# 训练分类器
gcf.fit(X_train, pd.DataFrame(Y_train).values.ravel())

# 模型保存
import joblib
joblib.dump(gcf, 'my_iris_model.sav')

